﻿#include "widget.h"
#include "ui_widget.h"

#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    picId = 2;
    QPixmap pix("d:/Pictures/Saved Pictures/1.jpg");
    ui->label->setPixmap(pix);


}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    //开启定时器
    myTimerId = this->startTimer(TIMEOUT);
}

void Widget::timerEvent(QTimerEvent *event)
{
    if(event->timerId() != myTimerId)
    {
        return;
    }
    qDebug()<<"dddddd";
    QString path("d:/Pictures/Saved Pictures/");
    path += QString::number(picId);
    path += ".jpg";

    QPixmap pix(path);
    ui->label->setPixmap(pix);

    picId++;
    if(picId >= 5)
    {
        picId = 1;
    }
}

void Widget::on_pushButton_2_clicked()
{
    this->killTimer(myTimerId);
}

